﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Cities
{
    public class CityNameSpecification : Specification<City>
    {
        #region public properties
        
        public string CityName
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public CityNameSpecification(string cityName)
        {
            this.CityName = cityName;
        }

        #endregion

        #region public methods

        public override Expression<Func<City, bool>> SatisfiedBy()
        {
            Specification<City> spec = new TrueSpecification<City>();
            spec &= new DirectSpecification<City>(c => c.Name == this.CityName);

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
